-- 
-- Relacion con COMM	
-- 

CREATE OR REPLACE FUNCTION public.tg_comm_del_upd_opepla()
    RETURNS trigger
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE NOT LEAKPROOF
AS $BODY$
BEGIN
  IF EXISTS (SELECT * FROM public.opepla WHERE estado = 'C' and OLD.NroOpePla = Nro ) then
     RAISE EXCEPTION 'No puede modificar o borrar un comprobante con su planilla de caja cerrada. Verifique';
  END IF;
  IF TG_OP = 'DELETE' THEN
    RETURN OLD;
  ELSE
    RETURN NEW;
  END IF;
END;
$BODY$;

ALTER FUNCTION public.tg_comm_del_upd_opepla()
    OWNER TO abacouser;


--
SELECT aaVersion('517.01','517.00');
--	
	
	


